import request from "@/utils/request";
import config from '@/settings';

export function loginByUsername(username, password) {
    const data = {
        username: username,
        password: password,
        ...config.oauth2
    };
    const formData = new FormData();
    Object.keys(data).forEach((key) => {
        formData.append(key, data[key]);
    });
    return request({
        url: "/api/oauth/token",
        method: "post",
        formData
    });
}

export function refreshToken() {
    const data = {};
    return request({
        url: "/api/oauth/token",
        method: "post",
        data
    });
}